<?php

/**
 * Comision form base class.
 *
 * @method Comision getObject() Returns the current form's model object
 *
 * @package    saveenergy
 * @subpackage form
 * @author     0
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseComisionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'compania_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Compania'), 'add_empty' => false)),
      'tarifa_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Tarifa'), 'add_empty' => false)),
      'consumoMin'  => new sfWidgetFormInputText(),
      'consumoMax'  => new sfWidgetFormInputText(),
      'is_ratio'    => new sfWidgetFormInputCheckbox(),
      'producto'    => new sfWidgetFormInputText(),
      'importe'     => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'compania_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Compania'))),
      'tarifa_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Tarifa'))),
      'consumoMin'  => new sfValidatorPass(),
      'consumoMax'  => new sfValidatorPass(),
      'is_ratio'    => new sfValidatorBoolean(array('required' => false)),
      'producto'    => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'importe'     => new sfValidatorPass(),
    ));

    $this->widgetSchema->setNameFormat('comision[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Comision';
  }

}
